
const product = {
    state: {
        accountType:'1', // 默认1普通用户 2商家 3配送人员
        userId:'',
        userInfo:{}, // 用户信息-
        villageInfo:{}, //小区信息
        wechatInfo:{} ,//授权的信息
        avatarUrl : 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
        canUseProduct:'',//可以使用的产品信息
        termOfValidityDate:'',//到期时间
    },
    mutations: {
        SET_USER: (state, obj) => {

            // console.log('执行的么',obj)

            // obj.userInfo.canBuyGift = obj.canBuyGift

            state.userId = obj.userId
            state.userInfo = obj.userInfo || {}
            state.villageInfo = obj.villageInfo || {}

            state.wechatInfo = obj.wechatDto

            if( obj.wechatDto ){
                state.avatarUrl = obj.wechatDto.headimgurl
            }

            state.accountType = obj.userInfo?.accountType || '1' 
        },
        SET_WXUSER: (state, obj) => {
      
            state.wechatInfo = obj

            if( obj.wechatDto ){
                state.avatarUrl = obj.headimgurl
            }
                       
        },
    },

    actions: {
        //获取字典
        getDict({ commit, state }) {
          
        },

    },
    getters:{
        accountType: state => state.accountType,
        userId: state => state.userId,
        userInfo: state => state.userInfo,
        villageInfo: state => state.villageInfo,
        wechatInfo: state => state.wechatInfo,
        headimgurl: state => state.headimgurl,
    }
}

export default product
